import { S } from '../../s';
import { IPSAppDEUILogic } from '../dataentity/ipsapp-deuilogic';
import { IPSAppDataEntity } from '../dataentity/ipsapp-data-entity';
import { IPSAppUILogic } from './ipsapp-uilogic';
import { IPSAppUILogicRefView } from './ipsapp-uilogic-ref-view';
import { PSSysViewLogicImpl } from '../../res/pssys-view-logic-impl';

export class PSAppUILogicImpl
  extends PSSysViewLogicImpl
  implements IPSAppUILogic
{
  get codeName(): string {
    return this.M.codeName;
  }

  protected psappdeuilogic: IPSAppDEUILogic;
  getPSAppDEUILogic(): IPSAppDEUILogic | null {
    if (this.psappdeuilogic != null) return this.psappdeuilogic;
    const value = this.M.getPSAppDEUILogic;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.psappdeuilogic = ipsappdataentity.findPSAppDEUILogic(value);
    }
    return this.psappdeuilogic;
  }

  protected psappdataentity: IPSAppDataEntity;
  getPSAppDataEntity(): IPSAppDataEntity | null {
    return (
      this.psappdataentity ||
      (this.psappdataentity = this.fillObjectModel(
        S._f,
        this.M.getPSAppDataEntity,
        S._2aa,
      ) as IPSAppDataEntity)
    );
  }

  protected psappuilogicrefviews: IPSAppUILogicRefView[];
  getPSAppUILogicRefViews(): IPSAppUILogicRefView[] | null {
    return (
      this.psappuilogicrefviews ||
      (this.psappuilogicrefviews = this.fillChildListModel(
        this.M.getPSAppUILogicRefViews,
        S._5,
      ) as IPSAppUILogicRefView[])
    );
  }

  findPSAppUILogicRefView(objKey: any): IPSAppUILogicRefView | null {
    return this.getPSModel5(
      S._5,
      this.getPSAppUILogicRefViews(),
      objKey,
    ) as IPSAppUILogicRefView;
  }

  get builtinLogic(): boolean {
    return this.M.builtinLogic != null ? this.M.builtinLogic : true;
  }

  get dynaInstModel(): boolean {
    return this.M.dynaInstModel != null ? this.M.dynaInstModel : false;
  }
  get cls(): string {
    return 'PSAppUILogicImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._280) return true;
    return super.instanceof(cls);
  }
}
